package com.google.code.greenplate;

import android.app.ListActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.AdapterView.OnItemClickListener;

public class ContactList extends ListActivity {
    /** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
	  super.onCreate(savedInstanceState);

	  setListAdapter(new ArrayAdapter<String>(this, R.layout.contactlist, CONTACTS));

	  ListView lv = getListView();
	  lv.setTextFilterEnabled(true);

	  lv.setOnItemClickListener(new OnItemClickListener() {
	    public void onItemClick(AdapterView<?> parent, View view,
	        int position, long id) {
	      // When clicked, show a toast with the TextView text
	      Toast.makeText(getApplicationContext(), ((TextView) view).getText(),
	          Toast.LENGTH_SHORT).show();

	    }
	  });
	}
	  static final String[] CONTACTS = new String[] {
		    "Dimitar Makariev", "Greg Cook", "Miro Beran", "Michelle Mooi", "Georgi Dagnall"
	  };
}
/*
    Called when the activity is first created.
	@Override
	public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.contactlist);
        
        Button createComm = (Button)findViewById (R.id.create_community);
        createComm.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                // launch the second activity from button  click.
                Intent intent = new Intent();
                intent.setClass(ContactList.this, UserLocation.class);
                startActivity(intent);
            }
        });   
    }
}
*/